package javari.game;

import org.anddev.andengine.engine.Engine;
import org.anddev.andengine.entity.scene.Scene;
import org.anddev.andengine.ui.activity.BaseGameActivity;

import org.anddev.andengine.engine.camera.Camera;
import org.anddev.andengine.engine.options.EngineOptions;
import org.anddev.andengine.engine.options.EngineOptions.ScreenOrientation;
import org.anddev.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;

import org.anddev.andengine.entity.scene.background.ColorBackground;
import org.anddev.andengine.entity.sprite.Sprite;
import org.anddev.andengine.entity.util.FPSLogger;
import org.anddev.andengine.opengl.texture.TextureOptions;
import org.anddev.andengine.opengl.texture.Texture;
import org.anddev.andengine.opengl.texture.region.TextureRegion;
import org.anddev.andengine.opengl.texture.region.TextureRegionFactory;



public class MainActivity  extends BaseGameActivity {
	

    private static final int CAMERA_WIDTH = 720;
    private static final int CAMERA_HEIGHT = 480;  

    private Camera _refCamera;
    private Texture _ballBitmapTexture;
    private TextureRegion _ballTextureRegion;

    

    @Override
    public Engine onLoadEngine() {
            this._refCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
            return new Engine(new EngineOptions(true, ScreenOrientation.PORTRAIT, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), this._refCamera));
    }

    @Override
    public void onLoadResources() {
            this._ballBitmapTexture =  new Texture(256,512,TextureOptions.BILINEAR_PREMULTIPLYALPHA);
            this._ballTextureRegion= TextureRegionFactory.createFromAsset(this._ballBitmapTexture, this, "gfx/javari.png", 0, 0); // 64x32
            this.mEngine.getTextureManager().loadTexture(this._ballBitmapTexture);
    }

    @Override
    public Scene onLoadScene() {
            this.mEngine.registerUpdateHandler(new FPSLogger());
             Scene scene = new Scene(2);         
             scene.setBackground(new ColorBackground(0.0000f, 0.0000f, 0.0000f));
            /* Calculate the coordinates for the face, so its centered on the camera. */
            final int centerX = (CAMERA_WIDTH - this._ballTextureRegion.getWidth());
            final int centerY = (CAMERA_HEIGHT - this._ballTextureRegion.getHeight());

            /* Create the face and add it to the scene. */
            final Sprite face = new Sprite(centerX, centerY, this._ballTextureRegion);          
            scene.getTopLayer().addEntity(face);
            return scene;
    }

    @Override
    public void onLoadComplete() {

    }
  
   
}